package org.malred
package lecture.part1basics

object ValuesVariablesTypes extends App {
  val x: Int = 42
  println(x)

  // vals are immutable(不可变)
  // x = 2 // error

  // compiler can infer types
  val x1 = 24
  println(x1)

  //  val aStr: String = "hello"; val anotherStr="goodbye"
  val aStr: String = "hello";
  val anotherStr = "goodbye"

  val aBool: Boolean = false
  val aChar: Char = 'a'
  val anInt: Int = x
  //  val aShort: Short = 46133333333 // 整数文字超出 Int 类型的范围
  val aShort: Short = 4613
  val aLong: Long = 4153461361461L
  val aFloat: Float = 2.0f
  val aDouble: Double = 3.14

  // 函数式编程更多使用不可变的val
  // variables
  var aVariable: Int = 4
  aVariable = 5 // side effects 有副作用
  println(aVariable)
}
